package com.atguigu.lease.common.exception;

import com.atguigu.lease.common.result.ResultCodeEnum;
import lombok.Data;

/**
 * projectName: com.atguigu.lease.common.exception
 *
 * @author: 赵伟风
 * description:
 *
 *  exception -> String message
 *            -> int code 错误码
 */



@Data
public class LeaseException extends RuntimeException{

    private int code ;  //装错误码

    public LeaseException(String message) {
        super(message);
    }

    /**
     * Constructs a new runtime exception with the specified detail message.
     * The cause is not initialized, and may subsequently be initialized by a
     * call to {@link #initCause}.
     *
     * @param message the detail message. The detail message is saved for
     *                later retrieval by the {@link #getMessage()} method.
     */
    public LeaseException(String message, int code) {
        super(message);
        this.code = code;
    }


    public LeaseException(ResultCodeEnum resultCodeEnum) {
        super(resultCodeEnum.getMessage());
        this.code = resultCodeEnum.getCode();
    }

}
